package com.hzit.controller;

import com.hzit.entity.Student;
import com.hzit.service.IStudentService;
import com.hzit.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hbxfwf
 * @since 2024-02-23
 */
@RestController
@RequestMapping("/student")
public class StudentController {
	@Autowired
	private IStudentService studentService;
	//1.  列表学生
	@GetMapping("/list")
	public R list(){
		return R.ok(studentService.list());
	}
	//2. 列表学生2 (RedisTemplate使用)
	@GetMapping("/list2")
	public R list2(){
		return R.ok(studentService.list2());
	}
	//3. 列表学生3 (StringRedisTemplate使用)
	@GetMapping("/list3")
	public R list3(){
		return R.ok(studentService.list3());
	}
	//4. 添加学生
	@PostMapping("/add")
	public R add(@RequestBody Student student){
		studentService.insert(student);
		return R.ok();
	}
}
